<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title></title>
    <!--{include file='comm/comm_editor.tpl'}-->
</head>
<body>

<div style="width:100%">

    <div class="items clearfix">
        <h2 style="" class="tal">正在操作：<!--{if $goods_brand_array}-->品牌修改<!--{else}-->品牌新增<!--{/if}--></h2>
        <div class="items2">

            <div>
                <form id="brand_form" onsubmit="return false;">
                    <table>
                        <tbody>
                        <tr>
                            <td class="tar" width="150">品牌名称：</td>
                            <td width="400">
                            	<input type="text" style="ime-mode:active;width:300px;" autocomplete="off"  name="brandName" maxlength="20" value="<!--{$goods_brand_array.brandName}-->">
                                <font color="red">*</font>
                                 <input type="hidden" name="brandID" id="brandID" value="<!--{$goods_brand_array.brandID}-->" />
                            </td>
                            <td rowspan="4" style="text-align:center;">
                            	<div id="pic_div" style="border: 1px solid #CCCCCC;height: 100px;margin: 0 auto;width: 100px;">
                            		<!--{if $goods_brand_array.logo}-->
                            			<img height="100px" width="100px" src="<!--{$goods_brand_array.logo}-->" />
                            		<!--{/if}-->
                            	</div>
                                <input type="button" class="btn" value="上传logo" style="margin:5px auto;" id="upload_img" />
                                <input type="hidden" name="brand_img" id="brand_img" value="" />
                            </td>
                        </tr>
                        <tr>
                            <td class="tar">品牌描述：</td>
                            <td>
                            	<textarea autocomplete="off" style="font-size:12px;ime-mode:active" rows="4" cols="50" name="description"><!--{$goods_brand_array.description}--></textarea>
                            </td>
                        </tr>
                         <tr>
                            <td class="tar">排列序号：</td>
                            <td>
                            	<input type="text" style="ime-mode:active;width:80px;" autocomplete="off"  name="sortOrder" maxlength="6" value="<!--{$goods_brand_array.sortOrder|default:$sort_num}-->">
                                <font color="red">*</font>
                            </td>
                        </tr>
                        <tr>
                            <td class="tar" >使用标志：</td>
                            <td>
                            	<!--{if !$goods_brand_array || $goods_brand_array.useFlg ==1 }-->
	                            	<input type="radio" checked="checked" value="1" name="useFlg">启用 
	                            	<input type="radio" name="useFlg" value="0">禁用 
                            	<!--{else}-->
                            		<input type="radio"  value="1" name="useFlg">启用 
	                            	<input type="radio" checked="checked" name="useFlg" value="0">禁用 
                            	<!--{/if}-->
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </form>
            </div>

        </div>
    </div>


    <div class="bottom_fixbox">
        <div class="rectbox tac">
        	<input type="button" class="btn" onclick="brand.reset();" value="重置" />&nbsp;&nbsp;
            <input type="button" class="btn" onclick="brand.check();" value="保存" />&nbsp;&nbsp;
            <input type="button" class="btn" onclick="E.closeWindows();" value="关闭" />
        </div>
    </div>



</div>

<script type="text/javascript">

    var brand = {
    	
        brandID: <!--{$goods_brand_array.brandID|default:0}-->,
        
        //检查数据
        check: function() {

            var dt = E.getFormValues("brand_form");
            var error_msg = "";
            if (dt.brandName == "")
                error_msg += "品牌名称不能为空<br />";
                
            if (!E.isInt(dt.sortOrder))
                error_msg += "排序序号必须为数字<br />";
                
            if (error_msg != "") {
                E.alert(error_msg);
            } else {
                E.ajax_post({
                    url: '/invokingAjax-backend/goods/brand.ajax?operFlg=2',
                    data: dt,
                    call: 'brand.result'
                });
            }

        },

        result: function( o ) {

            if (o.code == 200) {

                E.opener("brand.load");
                if (this.brandID) {
                    E.alert(o.message, 2, "E.closeWindows");
                } else {
                    E.alert(o.message, 2, "E.refresh");
                }

            } else {

                E.alert(o.message);

            }

        },

        //清除商品信息
        reset: function() {
            $("#brandName").val("");
            $("#description").val("");
            $("#show_img").html("");
            $("#brand_img").val("");
            $('input[name=useFlg]').get(0).checked = true;
        }

    };

    KindEditor.ready(function(K) {
        var editor = K.editor({
            allowFileManager : true,
            uploadJson: '/framework/kindeditor/php/upload_json.php?act=userdefined'
        });
        $("#upload_img").click(function() {
            editor.loadPlugin('image', function() {
                editor.plugin.imageDialog({
                    showRemote : false,
                    clickFn : function(url) {
                        $("#brand_img").val(url);
                        $("#pic_div").html('<img src="' + url + '" style="width:100px;height:100px;" />');
                        editor.hideDialog();
                    }
                });
            });
        });

    });

</script>

</body>

</html>
